<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class LaborTeamContract extends Model
{
    use HasFactory;

    protected $fillable = [
        'labor_team_id',
        'labor_company_id',
        'admin_id',
        'role_id',
        'company_id',
        'contract_type',
        'classified_budget_amount',
        'contract_number',
        'cpmpany_number',
        'bank',
        'nummber',
        'contact',
        'contract_price',
        'mothod',
        'taxes',
        'taxation_method',
        'progress_payment_ratio',
        'settlement_ratio',
        'signing_date',
        'signed_amount_by_category',
        'contract_name',
        'bank_number',
        'name',
        'management_expense',
        'company_name',
        'price',
        'tax_rate',
        'prepayment_ratio',
        'completion_payment_ratio',
        'Retention_money_ratio',
        'construction_content',
        'construction_method',
        'breach_of_contract',
        'contract_status',
        'remarks',
        'files',
    ];
    const POSTONLY = [
        'labor_team_id',
        'labor_company_id',
        'admin_id',
        'role_id',
        'company_id',
        'contract_type',
        'classified_budget_amount',
        'contract_number',
        'cpmpany_number',
        'bank',
        'nummber',
        'contact',
        'contract_price',
        'mothod',
        'taxes',
        'taxation_method',
        'progress_payment_ratio',
        'settlement_ratio',
        'signing_date',
        'signed_amount_by_category',
        'contract_name',
        'bank_number',
        'name',
        'management_expense',
        'company_name',
        'price',
        'tax_rate',
        'prepayment_ratio',
        'completion_payment_ratio',
        'Retention_money_ratio',
        'construction_content',
        'construction_method',
        'breach_of_contract',
        'contract_status',
        'remarks',
        'files',
    ];

    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
    }

    public function resources()
    {
        return $this->hasMany(ResourceBind::class,'source_id','id')->where('model','LaborTeamContract')->with('resource');
    }

}
